package com.wongleoi.weather_demo.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.wongleoi.weather_demo.R
import com.wongleoi.weather_demo.model.CityBean

/**

* @author wongleoi

* @classname WeatherMainFragment.kt

* @describe  城市天气主fragment

* @time 2022/7/15 20:52

*/
class WeatherMainFragment : Fragment() {

    private val mListFragment = WeatherListFragment()

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View = inflater.inflate(R.layout.weather_fragment_main, container, false)

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        childFragmentManager.beginTransaction()
            .replace(R.id.container, mListFragment)
            .commit()
    }

    /**
     * 跳转到城市天气详情
     */
    fun jumpToDetail(entity: CityBean) {
        findNavController().navigate(WeatherMainFragmentDirections.actionMainToDetail(entity))
    }
}

